﻿using UnityEngine;

namespace CGF
{
    public class ColliderLineUI : ColliderBase
    {
        public float radius = 1;
        public Vector2 lastPos { get; private set; }
        public Vector3 lastWorldPos { get; private set; }
        public RectTransform rectTransform { get; private set; }

        protected override void Awake()
        {
            base.Awake();
            rectTransform = transform as RectTransform;
        }

        public override void Init()
        {
            base.Init();
            RefreshLastPos();
        }

        public override void RefreshLastPos()
        {
            base.RefreshLastPos();
            if (rectTransform)
            {
                lastPos = rectTransform.anchoredPosition;
                lastWorldPos = transform.position;
            }
        }

#if UNITY_EDITOR
        private void OnDrawGizmos()
        {
            DrawGizmos();
        }
        public override void DrawGizmos()
        {
            base.DrawGizmos();
            Gizmos.color = Color.yellow;
            if (radius > 0)
            {
                Vector3 center = transform.position;
                center.z -= 0.1f;
                Gizmos.DrawWireSphere(center, radius * transform.lossyScale.x);
            }
        }
#endif
    }
}